var layerId;
var clickStatus=true;
$(function(){
	$("#search-button").click(function(){
		var keyword=$("input[name='keyword']").val();
		var status=$("select[name='status']").val();
		var startTime=$("input[name='startTime']").val();
		var endTime=$("input[name='endTime']").val();
		var goodsNumMin=$("input[name='goodsNumMin']").val();
		var goodsNumMax=$("input[name='goodsNumMax']").val();
		var payJeMin=$("input[name='payJeMin']").val();
		var payJeMax=$("input[name='payJeMax']").val();
		var url=basePath+"/order/query.shtml?pageNo=1"+"&keyword="+keyword+
		"&status="+status+"&startTime="+startTime+"&endTime="+endTime+"&goodsNumMin="+goodsNumMin
		+"&goodsNumMax="+goodsNumMax+"&payJeMin="+payJeMin+"&payJeMax="+payJeMax;
		window.location.href=url;
	});
})
function fanye(pageNo){
	var keyword=init.keyword;
	var status=init.status;
	var startTime=init.startTime;
	var endTime=init.endTime;
	var goodsNumMin=init.goodsNumMin;
	var goodsNumMax=init.goodsNumMax;
	var payJeMin=init.payJeMin;
	var payJeMax=init.payJeMax;
	var url=basePath+"/order/query.shtml?pageNo="+pageNo+"&keyword="+keyword+
	"&status="+status+"&startTime="+startTime+"&endTime="+endTime+"&goodsNumMin="+goodsNumMin
	+"&goodsNumMax="+goodsNumMax+"&payJeMin="+payJeMin+"&payJeMax="+payJeMax;
	window.location.href=url;
}

function sendGoods(orderId){
	layerId=layer.open({
		title: "修改话题",
		area: ['1200px','700px'],
		fix:true,
		type: 2,
		content: basePath+'/order/sendGoods.shtml?orderId='+orderId
	});
}
function showOrderDetail(orderId){
	layerId=layer.open({
		title: "订单详情",
		area: ['1200px','700px'],
		fix:true,
		type: 2,
		content: basePath+'/order/showDetail.shtml?orderId='+orderId
	});
}
function refundOrder(orderId){
	layerId=layer.open({
		title: "申请退货",
		area: ['60%','80%'],
		fix:true,
		type: 2,
		content: basePath+'/order/refundOrder.shtml?orderId='+orderId
	});
}
function updateStatus(orderId,status){
	if(confirm("确认操作？")){
		$.ajax({
			url:basePath+"/order/updateStatus.shtml?orderId="+orderId+"&status="+status,  
			type:"post",
			dataType:"JSON",
			success:ajaxSuccessRefreshFun
		});
	}
}
function payOrder(orderId,userMoney,totalJe){
	var money = Number(userMoney)-Number(totalJe);
	if(money<0){
		layer.msg("请确认账户余额是否足够支付订单！");
		return false;
	}
	if(confirm("确认审核？")){
		if(clickStatus){
			clickStatus =false;
			$.ajax({
				url:basePath+"/order/payOrder.shtml?orderId="+orderId,  
				type:"post",
				dataType:"JSON",
				success:ajaxSuccessRefreshFun
			});
		}
	}
}
